import React, { Component } from 'react';
import orderInfo from './info.module.scss'
import wechat from '../../static/ye.png'
import right from '../../static/right.png'
import { getOrder } from '../../utils/interface'
import { formatTime,getUrlParam } from '../../utils/tools'
import { divide } from '../../utils/maths'
class Info extends Component {
    constructor(props) {
        super(props);
        this.state = {
            details: null
        }
    }
    render() {
        console.log(this.state.details)
        return (
            <div className={orderInfo.wrap}>
                {this.state.details && this.state.details.orderNumber ? (<div><p className={orderInfo.title}>加油支付明细</p>
                    <div className={orderInfo.item}>
                        <p>订单号</p>
                        <p>{this.state.details.orderNumber}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>交易时间</p>
                        <p>{formatTime(new Date(this.state.details.createTime), '-')}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>油站名称</p>
                        <p>{this.state.details.storeName}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>油号</p>
                        <p>{this.state.details.oilNum}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>设备号</p>
                        <p>{this.state.details.terminalNo}</p>
                    </div>
                    {this.state.details.certificationTypeName? <div className={orderInfo.item}>
                    <p>认证类型</p>
                    <p>{this.state.details.certificationTypeName}</p>
                </div>:''}
                   
                    <div className={orderInfo.item}>
                        <p>加油金额</p>
                        <p>{divide(this.state.details.orderAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>加油升数</p>
                        <p>约{this.state.details.rise}L</p>
                    </div>
                    {/** 
                    <div className={orderInfo.item}>
                        <p>直降优惠</p>
                        <p className={orderInfo.price}>-￥{divide(this.state.details.downAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>满减优惠</p>
                        <p className={orderInfo.price}>-￥{divide(this.state.details.fullReductionAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>折扣优惠</p>
                        <p className={orderInfo.price}>-￥{divide(this.state.details.rebateAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>优惠券优惠</p>
                        <p className={orderInfo.price}>-￥{divide(this.state.details.couponAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.item}>
                        <p>红包优惠</p>
                        <p className={orderInfo.price}>-￥{divide(this.state.details.redPackedAmount, 100)}</p>
                    </div>
                    */}
                    <div className={orderInfo.money}>
                        <p>实付金额</p>
                        <p>￥{divide(this.state.details.payAmount, 100)}</p>
                    </div>
                    <div className={orderInfo.payType}>
                        <div>
                            <img src={wechat} alt="" />
                            <p>余额支付</p>
                        </div>
                        <p>￥{divide(this.state.details.payAmount, 100)}</p>
                    </div>
                    {/**<div className={orderInfo.invoice}>
                        <p>发票</p>
                        <div>
                            <p>到吧台出示此码开具发票</p>
                            <img src={right} alt="" />
                        </div>
                    </div> */}
                    </div>) : ''}
                    


            </div>
        );
    }
    componentDidMount() {
        console.log('')
        this.getDetail()
    }
    getDetail() {
      
        getOrder({ orderNumber: getUrlParam('orderNumber') }).then(res => {
            this.setState({
                details: res.data.result
            })
            console.log(this.state.details)
        })
    }
}

export default Info;